package com.fita.admin.entity.content;


import com.demo2do.core.persistence.support.QueryBuilder;
import com.demo2do.core.persistence.support.QueryFilter;
import com.demo2do.core.persistence.support.QueryOrder;

import java.util.Map;

/**
 * 
 * @author LZJ
 *
 */
public class CouponTemplateSearch implements QueryBuilder {
    
    /** 模版名称 */
    private String name;
    
    private QueryFilter filter;
    
    /**
     * default constructor
     */
    public CouponTemplateSearch() {
        
    }

    /* (non-Javadoc)
     * @see com.demo2do.core.persistence.support.QueryBuilder#getPreparedFilter(boolean)
     */
    public QueryFilter getPreparedFilter(boolean refresh) {
        if(filter == null || refresh) {

            filter = new QueryFilter().addLike("name", name)
                                 .addEquals("disabled", false);

        }

        return filter;
    }

    /* (non-Javadoc)
     * @see com.demo2do.core.persistence.support.QueryBuilder#buildSentenceTemplate()
     */
    public String buildSentenceTemplate() {
        return "FROM CouponTemplate " + getPreparedFilter(false).whereSentence();
    }
    

    /* (non-Javadoc)
     * @see com.demo2do.core.persistence.support.QueryBuilder#buildParameters()
     */
    public Map<String, Object> buildParameters() {
        return getPreparedFilter(false).parameters();
    }
    
 

    /**
     * @return the name
     */
    public String getName() {
        return name;
    }


    /**
     * @param name the name to set
     */
    public void setName(String name) {
        this.name = name;
    }


	@Override
	public QueryOrder getOrder() {
		// TODO Auto-generated method stub
		return null;
	}
}
